/*
 * @Author: anshengtyp
 * @Date: 2023-11-27 10:33:33
 * @LastEditTime: 2023-12-04 08:52:53
 * @LastEditors: anshengtyp
 * @Description:
 */
import request from "@/utils/request";

//获取任务列表
export function getTaskList(query) {
  return request({
    url: "/task/list",
    method: "get",
    params: query,
  });
}
//新建任务
export function newTask(data) {
  return request({
    url: `/task`,
    method: "post",
    data: data,
  });
}
//新建任务
export function editThisTask(data) {
  return request({
    url: `/task`,
    method: "put",
    data: data,
  });
}

//新建任务
export function deleteTask(id) {
  return request({
    url: `/task/${id}`,
    method: "delete",
  });
}
// 编辑任务
export function editTask(taskID, type, data) {
  return request({
    url: `/task/${taskID}/${type}`,
    method: "put",
    data: data,
  });
}

//获取任务列表
//新增任务
export function addTask(taskID, type, data) {
  return request({
    url: `/task/${taskID}/${type}`,
    method: "post",
    data: data,
  });
}

//获取生产技术详情
export function getTaskDetail(taskId, type, id) {
  return request({
    url: `/task/${taskId}/${type}/${id}`,
    method: "get",
  });
}

// 查询任务列表
export function queryTaskList(taskId, type) {
  return request({
    url: `/task/${taskId}/${type}/list`,
    method: "get",
  });
}

// 多个附件上传
export function moreCommonUpload(data) {
  return request({
    url: "/common/uploadsMinio",
    method: "post",
    data: data,
  });
}

//获取任务详细信息
export function getTask(id) {
  return request({
    url: "/task/" + id,
    method: "get",
  });
}

//获取质检列表
export function getQualityList(taskId, query) {
  return request({
    url: `/task/${taskId}/quality/list`,
    method: "get",
    params: query,
  });
}

// 发起办理流程
export function launchTask(taskId, type, id) {
  return request({
    url: `/task/${taskId}/${type}/${id}/wf/process/lanuch`,
    method: "post",
  });
}
// 发起新建任务流程
export function launchNewTask(taskId) {
  return request({
    url: `/task/${taskId}/wf/process/lanuch`,
    method: "post",
  });
}
// 新建任务审批
export function launchNewTaskApprove(taskId, data) {
  return request({
    url: `/task/${taskId}/wf/process/approve`,
    method: "post",
    data: data,
  });
}
// 新建任务办理过程
export function launchNewTaskProcessList(taskId) {
  return request({
    url: `/task/${taskId}/wf/process/list`,
    method: "get",
  });
}

// 审批流程
export function ApproveTask(taskId, type, id, query) {
  return request({
    url: `/task/${taskId}/${type}/${id}/wf/process/approve`,
    method: "post",
    data: query,
  });
}

// 获取审批流程日志
export function getApproveLogs(taskId, type, id) {
  return request({
    url: `/task/${taskId}/${type}/${id}/wf/process/list`,
    method: "get",
  });
}

// 获取计划列表
export function getPlanList(taskId) {
  return request({
    url: `/task/${taskId}/production-plan/list`,
    method: "get",
  });
}

// 新增生产计划
export function addPlan(taskId, data) {
  return request({
    url: `/task/${taskId}/production-plan`,
    method: "post",
    data: data,
  });
}

// 获取所有人员
export function getAllUser() {
  return request({
    url: `/system/user/extra/all`,
    method: "get",
  });
}

// 删除计划
export function deletePlan(taskId, id) {
  return request({
    url: `/task/${taskId}/production-plan/${id}`,
    method: "delete",
  });
}

// 编辑计划
export function editPlan(taskId, data) {
  return request({
    url: `/task/${taskId}/production-plan`,
    method: "put",
    data: data,
  });
}

// 新增生产进度
export function addNewProgress(taskId, data) {
  return request({
    url: `/task/${taskId}/progress`,
    method: "post",
    data: data,
  });
}
// 获取进度列表
export function getProgressList(taskId) {
  return request({
    url: `/task/${taskId}/progress/list`,
    method: "get",
  });
}
// 删除任务进度
export function deleteProgress(taskId, id) {
  return request({
    url: `task/${taskId}/progress/${id}`,
    method: "delete",
  });
}
// 修改任务进度
export function editProgress(taskId, data) {
  return request({
    url: `/task/${taskId}/progress`,
    method: "put",
    data: data,
  });
}

// 添加任务延期申请
export function addDelay(taskId, data) {
  return request({
    url: `/task/${taskId}/delay-request`,
    method: "post",
    data: data,
  });
}

// 获取任务延期申请列表
export function getDelayList(taskId) {
  return request({
    url: `/task/${taskId}/delay-request/list`,
    method: "get",
  });
}

//修改任务延期申请
export function editDelay(taskId, data) {
  return request({
    url: `/task/${taskId}/delay-request`,
    method: "put",
    data: data,
  });
}

// 获取技术管理办理过程
export function getJsProgress(taskId, type) {
  return request({
    url: `/task/${taskId}/${type}/wf/process/list`,
    method: "get",
  });
}

// 生产计划发起流程
export function startProductionPlan(taskId, type) {
  return request({
    url: `/task/${taskId}/${type}/wf/process/lanuch`,
    method: "post",
  });
}

// 生产计划审批流程
export function approveProductionPlan(taskId, type, data) {
  return request({
    url: `/task/${taskId}/${type}/wf/process/approve`,
    method: "post",
    data: data,
  });
}

// 生产计划获取办理过程
export function productionPlanProcessList(taskId, type) {
  return request({
    url: `/task/${taskId}/${type}/wf/process/list`,
    method: "get",
  });
}
// 延期申请获取办理过程
export function delayRequestProcessList(taskId, type, id) {
  return request({
    url: `/task/${taskId}/${type}/${id}/wf/process/list`,
    method: "get",
  });
}

// 延期申请审批
export function delayRequestProcess(taskId, type, id, data) {
  return request({
    url: `/task/${taskId}/${type}/${id}/wf/process/approve`,
    method: "post",
    data: data,
  });
}
// 延期申请删除
export function deleteDelayRequest(taskId, id) {
  return request({
    url: `/task/${taskId}/delay-request/${id}`,
    method: "delete",
  });
}

// 根据id获取任务编号
export function getTaskNo(id) {
  return request({
    url: `/task/taskNo?projectId=${id}`,
    method: "get",
  });
}
// 批量导入任务
export function importTask(data) {
  return request({
    url: `/task/import`,
    method: "post",
    data: data,
  });
}
